#ifndef LIB7ZIPARCHIVEHANDLER_H
#define LIB7ZIPARCHIVEHANDLER_H

#include <QCache>
#include <QStandardItemModel>
#include <QVariant>
#include <QMutex>
#include <QMutexLocker>
#include <QDebug>
#include <QFileInfo>
#include "lib7zip.h"
#include "archiveinstream.h"
#include "archiveqbytearraystream.h"
#include "utils.h"

class Lib7zipArchiveHandler : public QObject
{
    Q_OBJECT

public:
    Lib7zipArchiveHandler(QObject *parent = 0);
    ~Lib7zipArchiveHandler();

    QStandardItemModel *openArchiveFile(const QString &path);
    void closeWorkingArchive();
    QByteArray* dataAt(int index);
    QString workingFilePath();

private:
    C7ZipLibrary mLib7zip;
    C7ZipArchive *mArchive;
    ArchiveInStream *mInStream;
    QCache<int, QByteArray> *mImageCache;
    QMutex archiveReaderMutex;
    QString mWorkingFilePath;
};

#endif // LIB7ZIPARCHIVEHANDLER_H
